<?php
/**
 * Created by PhpStorm.
 * User: kongqi
 * Date: 2019/10/4
 * Time: 13:16
 */

namespace App\Plugin\HostServer\Models;


class PnHostSvSystemLog extends HostServerBase
{
   public static function getType($field=''){
       $type=[
           1=>'充值',
           2=>'购买服务器',
           3=>'续费服务器',
           4=>'退款',
           5=>'注册域名',
           6=>'续费域名',

       ];
       return $field==''?$type:$type[$field];
   }
    /**
     * 取得type 名字
     * @return array|mixed
     */
    public function getTypeNameAttribute()
    {
        return static::getType($this->type);
    }
    /**
     * 取得会员
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function user()
    {
        return $this->belongsTo(PnHostSvUser::class, 'user_id', 'id');
    }
    /**
     * 取得订单
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function order()
    {
        return $this->belongsTo(PnHostSvOrder::class, 'order_id', 'id');
    }
    public static function add($data){
        if($data['type']==4){
            $data['money']=$data['money'];
        }
        return self::create($data);
    }

}